package string;

public class StringBuilderDemo {
    public static void main(String[] args) {
        String str = "即使这样，他依然不放弃";
        StringBuilder stringBuilder = new StringBuilder(str);

        System.out.println(str);

        //append  在末尾增加
        stringBuilder.append("。");
        System.out.println(stringBuilder);

        //replace 替换部分内容(含头不含尾)
        stringBuilder.replace(9,12,"...");
        System.out.println(stringBuilder);

        //delete 删除
        stringBuilder.delete(110,12);
        System.out.println(stringBuilder);

        //insert 插入
        stringBuilder.insert(11,".");
        System.out.println(stringBuilder);














        StringBuilder s1 = new StringBuilder();
        StringBuilder s2 = new StringBuilder("abc");
        System.out.println(s1);
        System.out.println(s2);

        String s3 = s2.toString();
        String s4 = "abb";
        StringBuilder s5 = new StringBuilder(s4);
        System.out.println(s3);
        System.out.println(s4);
        System.out.println(s5);

    }
}
